#!/bin/bash

token=$1

pip3 install web.py==0.40.dev0 > /dev/null

[ $? -eq 0 ] && {
	[ -f /root/initialize-wechat-environment.zip ] && unzip -q -d /usr/local /root/initialize-wechat-environment.zip

	[ -f /usr/local/initialize-wechat-environment/handle.py ] && {
		sed -i "s/此处内容与公众号基本配置里Token字段取值保持一致/${token}/" /usr/local/initialize-wechat-environment/handle.py
		nohup python3 /usr/local/initialize-wechat-environment/main.py 80 > /dev/null 2>/usr/local/initialize-wechat-environment/wx.log &
	}
}

sed -i 's/^#Port 22/Port 5000/' /etc/ssh/sshd_config
sed -i 's/^PasswordAuthentication yes/PasswordAuthentication no/' /etc/ssh/sshd_config

systemctl restart sshd
